package cn.operation.api.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger2配置文件
 * 启动后访问地址：http://localhost:8080/swagger-ui.html
 * create by Felix
 */
@Configuration
@EnableSwagger2
public class Swagger2 {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //扫描提供接口的restcontroller
                .apis(RequestHandlerSelectors.basePackage("cn.operation.api.rest"))
                .paths(PathSelectors.any())
                .build();
    }
    //Swagger页面初始化内容
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("慧运车运营系统")
                .description("整合对外接口、后台调度、基础数据、结算等模块")
                .termsOfServiceUrl(" ")
                .contact("Felix")
                .version("1.0")
                .build();
    }
}
